import QtQuick 1.1
import com.nokia.symbian 1.1
import com.rogerio.apinfo 1.0

import "util.js" as Util

Page {
    id: root
    tools: ToolBarLayout {
        ToolButton {
            iconSource: "toolbar-back"
            onClicked: {
                pageStack.pop().destroy(500);
            }
        }
        ToolButton {
            iconSource: (item.marcado ? "toolbar-delete" : "toolbar-add")
            onClicked: {
                if (item.marcado)
                    vagasModel.Desmarcar(item.codigoVaga);
                else
                    vagasModel.Marcar(item.codigoVaga);
            }
        }
        ToolButton {
            iconSource: "qrc:///enviarEmail"
            onClicked: {
                pageStack.push(Qt.resolvedUrl("AlterarInfoBasicaPage.qml"), {"codigoVaga": item.codigoVaga});
            }
        }
    }

    property VagasItem item

    Rectangle {
        id: rectHeader
        width: parent.width-20; height: colIdVaga.height
        anchors.horizontalCenter: parent.horizontalCenter
        color: platformStyle.colorNormalDark
        z: 1

        Column {
            id: colIdVaga
            width: parent.width
            spacing: 4

            Text {
                id: txtCargoView
                text: item.cargo
                width: parent.width
                color: platformStyle.colorNormalLight
                font.pixelSize: 24
                wrapMode: Text.WordWrap
            }

            Text {
                id: txtEmpresaView
                text: item.empresa + " em " + Qt.formatDate(item.dataVaga, "dd/MM/yyyy")
                width: parent.width
                color: platformStyle.colorNormalLight
                font.pixelSize: 18
                wrapMode: Text.WordWrap
            }

            Text {
                id: txtVagaView
                text: "Código " + item.codigoVaga
                width: parent.width
                color: platformStyle.colorNormalLight
                font.pixelSize: 18
                wrapMode: Text.WordWrap
            }

            Text {
                id: txtContatoFeito
                visible: item.infoContato != undefined
                text: (item.infoContato != undefined ? "Contato realizado em " + Qt.formatDateTime(item.infoContato.dataContato, "dd/MM/yyyy HH:mm") : "")
                color: "red"
                font { pixelSize: 16; bold: true }
            }

            Row {
                width: parent.width
                spacing: 10
                Image {
                    id: bandeira
                    width: 32; height: 24
                    source: (item.estado !== "" ? "qrc:///estados/" + item.estado : "")
                    MouseArea {
                        width: parent.width; height: parent.height
                        onClicked: {
                            tooltipBandeira.abrirToolTip();
                        }
                    }
                }
                ToolTipAnimado {
                    id: tooltipBandeira
                    alvo: bandeira
                    texto: Util.SiglaParaEstado(estado);
                }
                Text {
                    text: cidade
                    color: platformStyle.colorNormalLight
                    font.pixelSize: 18
                }
            }

            Rectangle {
                width: parent.width; height: 1
                color: platformStyle.colorNormalLight
            }
        }

        IconeAnimado {
            id: imageGood
            source: "qrc:///good"
            x: colIdVaga.width - imageGood.width; y: txtCargoView.y            
            visibilidade: item.marcado
        }        
    }

    Flickable {
        width: rectHeader.width; height: parent.height - colIdVaga.height
        contentWidth: rectHeader.width; contentHeight: txtDescricaoView.height
        anchors.horizontalCenter: parent.horizontalCenter
        flickableDirection: Flickable.VerticalFlick
        y: colIdVaga.height

        Text {
            id: txtDescricaoView
            text: item.descricao
            width: parent.width
            color: platformStyle.colorNormalLight
            font.pixelSize: 16
            wrapMode: Text.WordWrap
        }
    }

}
